const http = require('http'),
url = require('url');

const urlObj = url.parse('http://168.39.0.78:8009', true);
var options = {
	host : urlObj.hostname,
	port : urlObj.port,
	path : urlObj.pathname,
	method : 'POST',
	headers : {
		'Accept' : 'application/json',
		'Content-Type' : 'application/json;charset=utf-8',
		'device_id' : '123',
		'bundleid' : 'com.nantian.mfp.msalary',
		'device_type' : 'iOS',
		'app_version' : '1'
	}
}
if (urlObj.search)
	options.path += urlObj.search;

function send(n) {
	if (n <= 0)
		return;
	const req = http.request(options, (res) => {
			var body = []
			res.on('data', (chunk) => {
				body.push(chunk)
			}).on('end', () => {
				var html = Buffer.concat(body).toString();
				//console.log(html)
				send(n - 1)
			}).on('error', (err) => {
				console.log(err)
			})
		});
	req.on('error', (err) => {
		console.log(err)
	})
	req.end()
}

var start_time = new Date().getTime()
for (var i = 0; i < 1; i++) {
	send(1)
}
console.log(new Date().getTime() - start_time)